<?php

session_start();

$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="smartinterview"; // Database name
$tbl_name="logintime_details"; // Table name
$name = $_SESSION['username'];
 

mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
 $updateQuery =  "UPDATE logintime_details SET logout_time=now(), Status='inactive' WHERE userID='$name'";
                  $result=mysql_query($updateQuery);
// if the user is logged in, unset the session
if (isset($_SESSION['logged-in'])) {
unset($_SESSION['logged-in']);
}
		 $status= "inactive";
$sql1="UPDATE login_details SET Status='$status' WHERE UserName='$name'";
$result1=mysql_query($sql1);
// now that the user is logged out,
// go to login page
header('Location: loginpage.php');
session_destroy();
?>